var jData = [
    { "id": "1175280", "title": "上海大众 帕萨特 1.8L 08款/11款/13-15款 嘉实多 小保养套餐", "oprice": "449.04", "price": "314.33", "src": "image/img2.jpg" },
    { "id": "1174837", "title": "广汽丰田凯美瑞 2.0L 2012-2015款 嘉实多 小保养套餐", "oprice": "364.94", "price": "255.46", "src": "image/img2.jpg" },
    { "id": "1176091", "title": "长安福特 翼博 1.5L 2013款 嘉实多 小保养套餐", "oprice": "347.36", "price": "243.15", "src": "image/img2.jpg" },
    { "id": "1176299", "title": "一汽马自达6 2.0L 2004-2015款 嘉实多 小保养套餐 ", "oprice": "366.26", "price": "256.38", "src": "image/img2.jpg" },
    { "id": "1175830", "title": "东风日产 骊威 1.8L 2010款 嘉实多 小保养套餐 ", "oprice": "363.84", "price": "254.69", "src": "image/img2.jpg" },
    { "id": "1175085", "title": "本田雅阁 2.4L 2013款 嘉实多 小保养套餐 ", "oprice": "363.84", "price": "254.69", "src": "image/img2.jpg" },
    { "id": "1176173", "title": "别克英朗 1.6L 2010-2014款 嘉实多 小保养套餐", "oprice": "244.94", "price": "171.46", "src": "image/img3.jpg" },
    { "id": "1176861", "title": "北京奔驰 c200 1.8T 2010款 嘉实多 小保养套餐 ", "oprice": "598.5", "price": "418.95", "src": "image/img4.jpg" },
    { "id": "1176627", "title": "华晨宝马 318i 2.0L 2008-2012款 嘉实多 小保养套餐 ", "oprice": "511.9", "price": "358.33", "src": "image/img4.jpg" }

]

var tData = [
    { "id": "1177587", "title": "韩泰轮胎205 55/R16 K407", "oprice": "365", "price": "279", "src": "image/img1.jpg" },
    { "id": "1177858", "title": "固特异轮胎205 55/R16 NCT5", "oprice": "410", "price": "319", "src": "image/img1.jpg" },
    { "id": "1177859", "title": "固特异轮胎195 65/R15 NCT5", "oprice": "340", "price": "259", "src": "image/img1.jpg" },
    { "id": "1177860", "title": "韩泰轮胎195/55R15 K407", "oprice": "320", "price": "249", "src": "image/img1.jpg" },
    { "id": "1177861", "title": "韩泰轮胎195 65/R15 H426", "oprice": "310", "price": "239", "src": "image/img1.jpg" },
    { "id": "1177862", "title": "邓禄普轮胎225/65R17  ST30", "oprice": "535", "price": "419", "src": "image/img1.jpg" },
    { "id": "1177863", "title": "邓禄普轮胎195 60/R16 SP270", "oprice": "430", "price": "329", "src": "image/img1.jpg" },
    { "id": "1177864", "title": "韩泰轮胎215/65R16  K415", "oprice": "390", "price": "299", "src": "image/img1.jpg" },
    { "id": "1177865", "title": "邓禄普轮胎205/55R16  SP-R1", "oprice": "370", "price": "279", "src": "image/img1.jpg" }

]

// 2.实例Vue对象
new Vue({
    el: '.g-box',
    data: {
        jiyouData: jData,
        tyreData: tData
    },
    methods: {
        // APP端接口
        getApp: function(key, value) {
            var appData = { "key": key, "value": value };
            // alert("key值是:"+key+",vlaue值是:"+value);
            //判断访问终端
            var browser = {
                versions: function() {
                    var u = navigator.userAgent,
                        app = navigator.appVersion;
                    return {
                        trident: u.indexOf('Trident') > -1, //IE内核
                        presto: u.indexOf('Presto') > -1, //opera内核
                        webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
                        gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核
                        mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
                        ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
                        android: u.indexOf('Android') > -1 || u.indexOf('Adr') > -1, //android终端
                        iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器
                        iPad: u.indexOf('iPad') > -1, //是否iPad
                        webApp: u.indexOf('Safari') == -1, //是否web应该程序，没有头部与底部
                        weixin: u.indexOf('MicroMessenger') > -1, //是否微信 （2015-01-22新增）
                        qq: u.match(/\sQQ/i) == " qq" //是否QQ
                    };
                }(),
                language: (navigator.browserLanguage || navigator.language).toLowerCase()
            }

            // 判断是安卓还是苹果
            if (browser.versions.android) {
                getAppData(JSON.stringify(appData));
            } else {
                var iver = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
                iver = parseInt(iver[1], 10);
                // IOS 8以上用webkit方法,IOS 8以下用UIWebview方法
                if (iver >= 8) {
                    // AppModel是OC所注入的对象
                    window.webkit.messageHandlers.AppModel.postMessage({ body: appData });
                } else {
                    getAppData(appData);
                }
            }
        }
    }
})